package org.yagnus.stats.sampler.discrete.withoutreplacement;

/**
 * 
 * @author hc.busy
 * 
 *         In the worst case, drawAll will in the worst case take time O(n^2) where n is the intial
 *         sample space size. (uniform distribution results in, on average, n^2 linked list
 *         traversals.) In that case, use UniformArraySampler which has worst case run time of O(n).
 * 
 *         FIXME: fix the len and numberSampled
 * 
 */
public class ListArraySampler2<BASETYPE> extends WithoutReplacementSampler<BASETYPE> {

    protected org.yagnus.stats.sampler.discrete.ListArraySampler<BASETYPE> internal;

    public BASETYPE take() {
        BASETYPE ret = internal.sample_wor();
        return ret;
    }

    public void addSample(BASETYPE t, double w) {
        internal.addSample_wor(t, w);
    }

    @Override
    protected void _init(BASETYPE[] t, double[] weights) {
        internal = new org.yagnus.stats.sampler.discrete.ListArraySampler<BASETYPE>(t, weights);
        internal.setReplacement(false);
    }

    @Override
    public void removeSample(BASETYPE t) {
        internal.removeSample_wor(t);
    }

    public ListArraySampler2(BASETYPE[] t, double[] weights) {
        super(t, weights);
    }

    public ListArraySampler2(BASETYPE[] t, long[] weights) {
        super(t, weights);
    }

    public ListArraySampler2(BASETYPE[] t, int[] weights) {
        super(t, weights);
    }

    public ListArraySampler2(BASETYPE[] t) {
        super(t);
    }

}
